﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Text;
using Tauren.Business.Entity.Const;

namespace Tauren.Business.Mapper
{
    public class RoleProfile : Profile, ICommProfile
    {
        public RoleProfile()
        {
            InitProfile();
        }

        public void InitProfile()
        {
            CreateMap<Entity.Model.Roleinfo, Entity.Output.Roleinfo_OutPut>().AfterMap((data, viw) =>
            {
                viw.Dic_Creatdate = data.Creatdate is null ? "" : data.Creatdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
                viw.Dic_Modifdate = data.Modifdate is null ? "" : data.Modifdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
            });
            CreateMap<Entity.Input.Roleinfo_InPut, Entity.Model.Roleinfo>();

            CreateMap<Entity.Input.RoleRes_InPut, Entity.Model.RoleRes>();
            CreateMap<Entity.Model.RoleRes, Entity.Output.RoleRes_OutPut>();

            CreateMap<Entity.Input.RolePermission_InPut, Entity.Model.RolePermission>();
            CreateMap<Entity.Model.RolePermission, Entity.Output.RolePermission_OutPut>();

            CreateMap<Entity.Input.RolePersoninfo_InPut, Entity.Model.RolePersonInfo>();
            CreateMap<Entity.Model.RolePersonInfo, Entity.Output.RolePersonInfo_OutPut>();

            CreateMap<Entity.Output.RoleInfoTable, Entity.Output.Roleinfo_OutPut>();

            CreateMap<Entity.Output.ModuleResouceTable, Entity.Output.ModuleResouces_OutPut>().AfterMap((data, viw) =>
            {
                viw.Dic_Creatdate = data.Creatdate is null ? "" : data.Creatdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
                viw.Dic_Modifdate = data.Modifdate is null ? "" : data.Modifdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
            });
        }
    }
}
